package com.example.wexcle.demos.web.controller;

import com.example.wexcle.demos.web.R;
import com.example.wexcle.demos.web.entity.Filex;
import com.example.wexcle.demos.web.service.IFilexService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author wzh
 * @since 2024-10-16
 */
@RestController
@RequestMapping("/file")
public class FilexController {
    @Autowired
    private IFilexService iFilexService;
    //文件保存成功将文件相关信息存入数据库，tydk-excle模块调用tydk-file文件，文件保存成功就调用保存文件信息模块
    //存取文件相关信息
    @ApiOperation("保存上传文件信息")
    @PostMapping("/save")
    public R save(@RequestBody Filex file){
        boolean save = iFilexService.save(file);
        if(save == true){
            //成功是code为20000
            return R.ok();
        }
        //失败code为20001
        return  R.error();
    }
    @ApiOperation("查询导入文件的信息")
    @PostMapping("/selectall")
    public R selectall(){
        List<Filex> list = iFilexService.list();
        return R.ok().data("list",list);
    }

}
